<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.io.*, java.sql.*, java.util.*,LS.*, date.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html lang="UTF-8">
<style>
th,td {
	padding-bottom: 5px;
	padding-top: 5px;
}

#title{
	font: 17px; 
	font-weight:bold;
	text-align: right;
	width: 90px;
}

#result{
	text-align:left;
}

#content{
	text-align: left;
}
.txta{
	width:100%;
	height:100%;
}


b.text{
	font-size: 25px;
	margin-bottom: 10px;
}
h4,h1 {
	margin: 0px;
	padding: 0px;
}
th{
	height:30px;
	border-right: 1px solid #e5e5e5;
	border-bottom: 1px solid #e5e5e5;
}
tr{
	border-bottom: 1px solid #e5e5e5;
}
table {
	width: 100%;
}

.explain{
	color: red;
	font-size: 11px;
	border-bottom: 2px;
}
#outerview {
	padding-top: 10px;
	margin-left: 0px;
	text-align: center;
	background-color: #fff;
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
#outerview {
	width: 93%;
	min-height: 600px;
	padding: 0px;
}
#middleview{
	width: 90%;
	height: 450px;
	margin: 20px auto 0px auto;
	left: 50%;
	
}
#innerview {
	width: 100%;
 	height: 100%;
 	text-align: center;
	background-color: #fff;
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
} 

#innerviewleft,#innerviewright{
	margin-left:0px;
	padding-left:0px;
}

#plusview {
	margin:10px;
	margin-bottom:0px;
	text-align: left;
}
.tableview{
	width:100%;
	max-height:100%;
	left:50%;
}

.lendingdate{
	width:20%;
}
.notify{
	width:10%;
}
</style>
<head>
	<!-- styles시트 -->
	
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
	<script src="/LSsystem/assets/js/bootstrap.min.js"></script>
	<link href="/LSsystem/assets/css/bootstrap.css" rel="stylesheet">
	<link rel="stylesheet" href="/LSsystem/assets/css/bootstrap.css">
	<script type="text/javascript">
		function init(){
			$("#submit").click(f1);
		}
		
		function f1(){
			$("#form1").submit();
		}
		
		function beforeSubmit() {
			if($("#select1").val() != $("#esck").val()) {
				
				if($("#lsck").val() == "1" || $("#waitck").val() == "1") {
					alert("대여중인 기자재는 기자재 상태 변경이 불가합니다.");
					return false;
				}
			} else {
				alert("수정 완료.");
				return true;
			}
		}
		
		$(document).ready(init);
	</script>
</head>
<body>
<div class="container">
			<div id="outerview">
				<div id="middleview">
<!-- 					<form method="post" action="/LSsystem/notice.do"> -->
					<div id="plusview" >
							<b class="text">기자재 정보 수정</b>&nbsp;&nbsp;
					</div>
<!-- 					<div id="innerview"> -->
					<form onsubmit="return beforeSubmit()" id="form1" method="get" action="modifyEquipBtn.do">
						<div id="innerviewleft" class="span10">
							<br>
							<br>
							<div id="title" class="span2">일련번호</div><div id="content" class="span2">${equip.equipment_id}</div><br><br>
																		<input type="hidden" name="equipment_id" value="${equip.equipment_id }">
							<div id="title" class="span2">모델명</div><div id="content" class="span2"><input type="text" name="model_name" value="${equip.model_name}"></div><br><br>
							<div id="title" class="span2">가격</div><div id="content" class="span2"><input type="text" name="price" value="${equip.price}"></div><br><br>
							<div id="title" class="span2">입고날짜</div><div id="content" class="span2">${equip.getDateShort()}</div><br><br>
							<div id="title" class="span2">대여상태</div><div id="content" class="span3">${equip.getL()}<c:if test="${stuInfo != null }">
							(${stuInfo.name } ${stuInfo.user_id })
							</c:if>
							</div><br><br>
							<div id="title" class="span2">기자재상태</div><div id="content" class="span3">
							
							<% String u = ""; String un = ""; %>
							
							<c:if test="${equip.equipment_state == 'usual'}">
								<% u = "SELECTED"; %>
							</c:if>
							<c:if test="${equip.equipment_state == 'unusual'}">
								<% un = "SELECTED"; %>
							</c:if>
							<c:choose>
								<c:when test="${equip.lending_state == '1' || equip.waitlending == '1'}">
									<c:if test="${equip.equipment_state == 'usual'}">
										<div>사용가능</div>
									</c:if>
									<c:if test="${equip.equipment_state == 'unusual'}">
										<div>사용불가</div>
									</c:if>
								</c:when>
								<c:otherwise>
									<div>
									<select id="select1" name="equipment_state">
										<option value="usual" <%= u %>>사용가능</option>
										<option value="unusual" <%= un %>>사용불가</option>
									</select>
									</div>
								</c:otherwise>
							</c:choose>
							</div>
							
							
							
							<div id="title" class="span3">소속학과</div><div id="content" class="span2">${depart}</div><br><br>
							<div id="title" class="span2">용도</div><div id="content" class="span2">
								<select id="itemname" name="using_id" style="width: 200px;">
										<c:forEach var="using" items="${using}">
											<c:choose>
												<c:when test="${using.using_id == equip.using_id}">
													<option value="${using.using_id}" selected>${using.using}</option>
												</c:when>
												<c:otherwise>
													<option value="${using.using_id}">${using.using}</option>
												</c:otherwise>
											</c:choose>
										</c:forEach>
								</select></div><br><br>
							<div id="title" class="span2">품목명</div><div id="content" class="span2">
								<select id="itemname" name="item_id" style="width: 200px;">
										<c:forEach var="item" items="${item}">
											<c:choose>
												<c:when test="${item.item_id == equip.item_id}">
													<option value="${item.item_id }" selected>${item.item_name }</option>
												</c:when>
												<c:otherwise>
													<option value="${item.item_id }">${item.item_name }</option>
												</c:otherwise>
											</c:choose>
										</c:forEach>
								</select></div><br><br>
							<div id="title" class="span2">신청 여부</div><div id="content" class="span2">${equip.getW()}</div><br><br>
							<div id="title" class="span8">비고</div><div id="content" class="span4"><textarea name="note" class="txta">${equip.note}</textarea></div>
							<input type="hidden" name="what" value="1">
						</div>
						
						<div  style="text-align: right;">
						<input type="submit" class="btn" id="submit" value="수정 완료">
						<Button class="btn" onclick="location.href='modifyEquipBtn.do?equipment_id=${equip.equipment_id}&what=2'">기자재 폐기</Button>
						<Button class="btn" onclick="parent.smartPopClose(); return false;" >취소</Button>
						</div>
						
						</form>
<!-- 					</div> -->
					
<!-- 					</form> -->
				</div>
			</div>
		</div>
</body>
</html>